<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>浮动定位</title>
    <style>
        /*如果某个元素的所有子元素全部浮动则自动识别的高度为0,
        会导致后面的元素顶上来,产生不可预估的效果,给元素添加overflow:hidden即可解决*/
        body>div{
            width: 200px;
            border: 1px solid red;
            overflow: hidden;
        }
        div>div{
            width: 50px;
            height: 50px;
        }
        #d1{background-color: red;
            float: left;}
        #d2{background-color: green;
            float: left;}
        #d3{background-color: blue;
            float: left;}
        ul{
            list-style-type: none;/*去掉图标*/
            padding: 0;
            margin: 0;
            overflow: hidden;
        }
        li{
            float: left;
            margin-left: 20px;
        }
        a{
            text-decoration: none;
            color: #000;
        }
    </style>

</head>
<body>
<ul>
    <li><a href="">首页</a></li>
    <li><a href="">免费课</a></li>
    <li><a href="">直播课</a></li>
    <li><a href="">精品课</a></li>
    <li><a href="">线上班</a></li>
</ul>
<div>
  <div id="d1"></div>
  <div id="d2"></div>
  <div id="d3"></div>
</div>
</body>
</html>